Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RS setup scripts updates #1496

Merged
merged 34 commits into from
Nov 1, 2024
Merged

Conversation

basiliskus
Copy link
Contributor

@basiliskus basiliskus commented Oct 25, 2024

RS setup scripts updates

  • Consolidated RS setup scripts into one to simplify process
  • Updated RS Setup instructions
  • Improved handling of shared variables by adding .env file template
  • Consolidated readme files into one to have one place where scripts are documented
  • Refactored scripts in /scripts for separation of concerns, code reusability, maintenance and discoverability
  • Updated to reference files with absolute paths so scripts can be moved and run anywhere

Issue

#1488

Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

1488 - Fully compliant

Fully compliant requirements:

  • Add script to automate updating RS org settings for local testing
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Hardcoded Paths
The script contains hardcoded paths for keys and settings, which might not be flexible for different environments or users.

Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
Possible bug
Check and ensure environment variables are set before use to prevent runtime errors

Ensure that the CDCTI_HOME environment variable is set before using it to construct
the flexion_key path to avoid potential runtime errors.

scripts/rs/load-etor-org-settings.sh [16]

+if [ -z "$CDCTI_HOME" ]; then
+  echo "CDCTI_HOME is not set. Please set it before running this script."
+  exit 1
+fi
 flexion_key="$CDCTI_HOME/mock_credentials/organization-trusted-intermediary-public-key-local.pem"
Suggestion importance[1-10]: 9

Why: This suggestion is highly relevant as it prevents the script from failing due to an unset CDCTI_HOME environment variable, which is crucial for constructing paths in the script.

9
Ensure critical environment variables are set before use to prevent script failure

Add error handling to check if the RS_HOME environment variable is set before
changing the directory, to prevent the script from failing silently if the variable
is not set.

scripts/rs/reset.sh [9]

+if [ -z "$RS_HOME" ]; then
+  echo "RS_HOME is not set. Please set it before running this script."
+  exit 1
+fi
 cd "$RS_HOME"
Suggestion importance[1-10]: 9

Why: This suggestion is crucial as it adds necessary error handling for an unset RS_HOME environment variable before attempting to change directories, which is essential for the script's successful execution.

9
Verify the availability of necessary commands before execution to avoid runtime failures

Consider adding a check to ensure that the prime command is available and executable
before attempting to run it to set multiple settings and add keys.

scripts/rs/load-etor-org-settings.sh [10-20]

+if ! command -v ./prime &> /dev/null
+then
+  echo "prime command could not be found"
+  exit
+fi
 ./prime multiple-settings set -s -i ./settings/STLTs/Flexion/flexion.yml
 ...
 ./prime organization addkey --public-key $flexion_key --scope "flexion.*.report" --orgName flexion --kid flexion.simulated-sender --doit
Suggestion importance[1-10]: 8

Why: This suggestion is very important as it ensures the prime command is available and executable before running it, which is critical for the script's operations and prevents runtime errors.

8
Maintainability
Remove duplicate lines to improve script clarity and maintainability

Remove the duplicate export of CDCTI_HOME to clean up the script and avoid
confusion.

scripts/start-here.sh [3-5]

-export CDCTI_HOME="/path/to/trusted-intermediary"
 export CDCTI_HOME="/path/to/trusted-intermediary"
Suggestion importance[1-10]: 7

Why: Removing the duplicate export of CDCTI_HOME improves the script's clarity and maintainability, making it easier to read and manage.

7

…me of the envars. Also working of having absolute paths so the scripts could run from anywhere
…ov/trusted-intermediary into story/1488/rs-setup-scripts-updates
- Use new setup-rs.sh script
- Add alternate ways to build and run RS
- Fixed RS docs URL
- Clean up and simplify
@basiliskus basiliskus marked this pull request as ready for review October 30, 2024 15:28
@basiliskus
Copy link
Contributor Author

/review

Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

1488 - Fully compliant

Fully compliant requirements:

  • Add script to automate updating RS org settings for local testing
  • Refactor scripts in /scripts for separation of concerns, code reusability, maintenance and discoverability
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Script Path Hardcoding
The script paths are hardcoded which might cause issues if the environment or directory structure changes. Consider using environment variables or relative paths.

Hardcoded URLs
The script contains hardcoded URLs which could lead to maintenance issues or errors if the URLs change or need to be different per environment.

scripts/lib/submission-utils.sh Show resolved Hide resolved
scripts/setup/setup-reportstream.sh Show resolved Hide resolved
scripts/ti.sh Show resolved Hide resolved
CURRENT_DIR=$(pwd)
cd "$RS_HOME" || exit

# source "./prime-router/.vault/env/.env.local"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this comment means

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed that. We don't need it so will remove it


#### Requirements

- hurl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be helpful to add links to installation pages for the requirements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the links to the Resources section at the bottom so we don't have multiple repeated URLs

@basiliskus basiliskus requested a review from pluckyswan October 31, 2024 18:07
Copy link

@basiliskus basiliskus merged commit fbad979 into main Nov 1, 2024
17 checks passed
@basiliskus basiliskus deleted the story/1488/rs-setup-scripts-updates branch November 1, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants